package jmu.edu.yjc.controller;

import jmu.edu.yjc.domain.ResponseResult;
import jmu.edu.yjc.domain.entity.Comment;
import jmu.edu.yjc.domain.vo.comment.CommentVo;
import jmu.edu.yjc.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yjc
 * @date 2023/4/14 0:57
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Resource
    private CommentService commentService;
    @GetMapping("/rootList")
    public ResponseResult getRootList(Integer pageNum, Integer pageSize, Long aid) {
        return commentService.getRootList(pageNum,pageSize,aid);
    }
    @PostMapping("/addRootComment")
    public ResponseResult addRootComment(@RequestBody Comment comment) {
        return commentService.addRootComment(comment);
    }
    @GetMapping("/getRootCommentMore")
    public ResponseResult getRootCommentMore(Integer commentNum, Integer commentSize,Long aid, Long rootCommentId) {
        return commentService.getRootCommentMore(commentNum, commentSize, aid, rootCommentId);
    }
    @PostMapping("/addComment")
    public ResponseResult addComment(@RequestBody Comment comment) {
        return commentService.addComment(comment);
    }
    @DeleteMapping("/deleteComment/{id}")
    public ResponseResult deleteComment(@PathVariable("id") Long id) {
        commentService.removeById(id);
        return ResponseResult.okResult();
    }
    @DeleteMapping("/deleteChildrenComment/{id}")
    public ResponseResult deleteChildrenComment(@PathVariable("id") Long id) {
        return commentService.deleteChildrenComment(id);
    }
}
